package com.rivulet.doj_backend.depend;

import org.springframework.context.MessageSource;

import java.util.Collections;

public final class RestResponses {
    private final MessageSource messageSource;

    public RestResponses(MessageSource messageSource) {
        this.messageSource = messageSource;
    }

    public RestResponse ok() {
        return this.ok((Object)null);
    }

    public RestResponse ok(Object result) {
        return this.build(CommonStatus.ok, result);
    }

    public <T> RestResultResponse<T> ok2(T result) {
        return RestResponseBuilder.builder(CommonStatus.ok).result(result).messageSource(this.messageSource).build3(new Object[0]);
    }

    public RestResponse okEmptyMapIfResultNull(Object result) {
        return this.build(CommonStatus.ok, result == null ? Collections.emptyMap() : result);
    }

    public RestResponse build(Status status, Object result) {
        return this.build(status, result, new Object[0]);
    }

    public RestResponse build(Status status, Object result, Object[] args) {
        return RestResponseBuilder.builder(status).result(result).messageSource(this.messageSource).build(args);
    }

    public <T> RestResultResponse<T> build3(Status status, T result, Object[] args) {
        return RestResponseBuilder.builder(status).result(result).messageSource(this.messageSource).build3(args);
    }

    public RestResponse build2(Status status, Object... args) {
        return this.build(status, (Object)null, args);
    }

    public RestResponse error() {
        return this.error(CommonStatus.error);
    }

    public RestResponse error(Status status) {
        return this.build(status, (Object)null);
    }
}